package com.aaa.car.controller;

import com.aaa.car.entity.CarType;
import com.aaa.car.entity.Shop;
import com.aaa.car.service.ShopService;
import com.aaa.common.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * (Shop)表控制层
 *
 * @author YuXin
 * @since 2020-11-19 19:37:58
 */
@RestController
@RequestMapping("shop")
public class ShopController {
    /**
     * 服务对象
     */
    @Resource
    private ShopService shopService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Shop selectOne(Integer id) {
        return this.shopService.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param
     * @param
     * @return 对象列表
     */
    @GetMapping("queryAllByParam")
    public Result queryAllByParam(Integer pageNo, Integer pageSize, Shop shop) {
        return this.shopService.queryAllByParam(pageNo, pageSize, shop);
    }

    /**
     * 查询多条数据
     *
     * @param
     * @param
     * @return 对象列表
     */
    @PostMapping("queryAll")
    public  List<Shop> queryAll(@RequestBody  Shop shop) {
        return  this.shopService.queryAll(shop);
    }
    /**
     * 新增数据
     *
     * @param shop 实例对象
     * @return 实例对象
     */
    @PostMapping("insert")
    public Shop insert(@RequestBody Shop shop) {
        shop.setAddtime(new Date());
        this.shopService.insert(shop);
        return shop;
    }

    /**
     * 修改数据
     *
     * @param shop 实例对象
     * @return 实例对象
     */
    @PutMapping("update")
    public Shop update(@RequestBody Shop shop) {
        return this.shopService.update(shop);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @DeleteMapping("deleteById")
    public boolean deleteById(Integer id) {
        return this.shopService.deleteById(id);
    }
}